package com.my.zl.common.enums.resp;

/**
 * 通用应答码
 * @author Administrator
 *
 */
public enum GlobalEnum implements RespEnum{
    /** 成功*/
    SUCCESS("GLOBAL_SUCCESS", "Success"),
    /** 失败*/
    ERROR("GLOBAL_ERROR", "Error"),
    /** 主键重复*/
    DUPLICATE_PRIMARY_KEY("GLOBAL_DUPLICATE_PRIMARY_KEY", "Duplicate primary key."),
    /** 主键获取失败*/
    ERROR_PRIMARY_KEY("GLOBAL_ERROR_PRIMARY_KEY", "Error primary key."),
    
    DATABASE_NOT_SUPPORTED("GLOBAL_DATABASE_NOT_SUPPORTED", "Database not supported"),
    
    MISSING_FILE("GLOBAL_MISSING_FILE", "Missing file"),
    
    INVALID_PARAMETER("GLOBAL_INVALID_PARAMETER","Invalid parameter"),
    
    /** 无权限*/
    UNAUTHORIZED("GLOBAL_UNAUTHORIZED", "Unauthorized"),
    /** 未找到*/
    NOT_FOUND("GLOBAL_NOT_FOUND", "Not found"),
    /** 数据库连接失败*/
    DATABASE_CONNECT_FAILED("GLOBAL_DATABASE_CONNECT_FAILED", "Database connect failed"),
    
    METHOD_NOT_IMPLEMENTED("GLOBAL_METHOD_NOT_IMPLEMENTED","Method not implemented"),
    
    DataFormatException("4", "DataFormat exception"),
    DataNotExistException("5", "DataNotExistException"),
    TimeFormatException("6","TimeFormat Exception"),
    PictureFormatException("7","PictureFormat Exception"),
    IllegalArgumentException("8","IllegalArgumentException"),
    TOKEN_INVALID_OR_OVERDUE_EXCEPTION("GLOBAL_TOKEN_INVALID_OR_OVERDUE_EXCEPTION", "Token invalid or overdue exception"),
    AuthorizationCodeError("10", "authorization code error"),
    WrongSignatureException("11","Wrong Signature Exception"),
    SystemException("50", "system Exception"),
    MissingServletRequestParameter("400","Missing servletRequest parameter"),
    TypeMismatchException("401","Request parameter Type not match"),
    RequestMethodNotAllowed("405","Request method  not Allowed"),
    ;
    private String code;
    private String msg;

    GlobalEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public String getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    
    public static String msg(String code) {
        for (GlobalEnum m : GlobalEnum.values()) {
            if (m.getCode() == code) {
                return m.getMsg();
            }
        }
        return null;
    }
}